import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { resolve } from 'path';
// const target = 'http://172.20.150.229:8081';
// const target = 'https://jianmuci.dghub.cn';
// const target = 'https://ci.test.jianmuhub.com';
const target = 'http://127.0.0.1:8801';
const changeOrigin = false;
// https://vitejs.dev/config/
export default defineConfig({
  base: './',
  plugins: [
      vue(),
      AutoImport({
        resolvers: [ElementPlusResolver()],
      }),
      Components({
        resolvers: [ElementPlusResolver()],
      }),
  ],
  resolve: {
    alias: {
      '@': resolve(__dirname, 'src'),
    },
  },
  server: {
    host: '0.0.0.0',
    port: 8888,
    // 配置服务端代理
    proxy: {
      // worker
      '/workers': { target, changeOrigin },
      // 密钥管理
      '/secrets': { target, changeOrigin },
      // 流程定义
      '/projects': { target, changeOrigin },
      '/git': { target, changeOrigin },
      '/webhook': { target, changeOrigin },
      // 流程执行中心
      '/workflow_instances': { target, changeOrigin },
      '/logs': { target, changeOrigin },
      // 查询
      // '/view': { target, changeOrigin },
      // 节点库
      '/library': { target, changeOrigin },
      // 触发器
      '/trigger': { target, changeOrigin },
      // '/xxx': {
      //   target: 'http://xxx.xxx.xxx.xxx',
      //   // 发送请求头中，host会设置成target
      //   changeOrigin: true,
      // },
    },
  }
})
